#ifndef TIMETABLE_H
#define TIMETABLE_H
#include <iostream>
#include "TimeTableItem.h"
#include "Time.h"
#include "Date.h"
class TimeTable
{
public:
    TimeTable() = default;
    TimeTable(Time s, Time e, Date d, int delta, int runningTime);

    ~TimeTable()
    {
//        delete[] dueItems;
    }
    void printTable() const
    {
        printf("编号\t起始时间\t结束时间\t方向\n");
        int i = 0;
        for(i = 0; i < number; i++)
        {
            cout<<i+1<<"\t"<<dueItems[i].getStartTime()<<"\t"<<dueItems[i].getEndTime();
            if(dueItems[i].getDirection())
            {
                cout<<"\t返"<<endl;
            }else
            {
                cout<<"\t往"<<endl;
            }
        }
    }
    inline int getHeight() const {return number+1;}

protected:
    TimeTableItem *dueItems;
    int number;
    Date date;
};

class RunningTable: public TimeTable
{
private:
    TimeTableItem *actualItems;
public:
    RunningTable() : TimeTable(){};
    RunningTable(Time s, Time e, Date d, int delta, int runningTime);
    ~RunningTable() {
//        delete[] actualItems;
    }
    void setTimeItem(int num, const Time &start, const Time &end);
    void printCompleteTable();
    double getCarryRate(int);
    double getTimeRate();
    inline void setDate(Date date1) {date = date1;}
    inline TimeTableItem& getItem(int i) {return actualItems[i];}
};
#endif
